package Threaddemo.thread_0917;

import java.util.concurrent.CountDownLatch;

public class demo10_0519 {
    public static void main(String[] args) throws InterruptedException {
        CountDownLatch countDownLatch = new CountDownLatch(10);
        for (int i = 0; i < 10; i++) {
            int id = i;
            new Thread(() -> {
                System.out.println("子线程" + Thread.currentThread().getName() + "开始执行");
                try {
                    Thread.sleep(5000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                countDownLatch.countDown();
            },id + "").start();
        }
        countDownLatch.await();
        System.out.println("任务执行完毕");
    }

}
